import { observable, action } from 'mobx';
import { Browser, ListAdvanced } from 'weaver-mobile-page';

const initState = {
  browser: new Browser.Store({ route: '/test/browser' }),
  browserWithId: new Browser.Store({ route: '/test/browser', id: 'withid' }),
  group: new Browser.GroupStore([{ route: '/test/browser' }, { id: 'zidingyi' }]),
  listAd: new ListAdvanced.Store({ route: '/test/list-advanced' }),
};

export default class testStore {

  @observable browser = initState.browser;
  @observable browserWithId = initState.browserWithId;
  @observable group = initState.group;
  @observable listAd = initState.listAd;

  @action
  setState = (params = {}) => {
    Object.keys(params).forEach(key => {
      this[key] = params[key];
    });
    return this;
  }

  @action
  clear = () => this.setState(initState)

}
